package demo.anno;

/**
 * @Author dw
 * @ClassName TestAnnotation
 * @Description 自定义注解使用
 * @Date 2022/1/10 21:42
 * @Version 1.0
 */
@MyController(value = "我是指定注解value")
public class TestAnnotation {

    public static void main(String[] args) {
        try {
            TestAnnotation testAnnotation = new TestAnnotation();
            Class<? extends TestAnnotation> aClass = testAnnotation.getClass();
            //判断person对象上是否有Info注解
            if (aClass.isAnnotationPresent(MyController.class)) {
                System.out.println("TestAnnotation类上配置了MyController注解！");
                //获取该对象上Info类型的注解
                MyController myController = aClass.getAnnotation(MyController.class);
                System.out.println("myController.value :" + myController.value() + ", myController.des:" + myController.des());
            } 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}